--行矩不移
local xingjubuyi = fk.CreateSkill {
    name = "mcdh_xingjubuyi",
    tags = {Skill.Compulsory}
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

xingjubuyi:addEffect(fk.EventPhaseStart,{
    can_trigger = function(self, event, target, player, data)
        if not player:hasSkill(self) then return false end
        return target.phase == Player.Discard and target:getHandcardNum() > target.hp
    end,
    on_use = function(self, event, target, player, data)
        target:setChainState(true)
    end,
})

xingjubuyi:addEffect(fk.Death,{
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(self, false, true)
    end,

    on_use = function(self, event, target, player, data)
        player:getNextAlive():addSkill(self)
    end,
})

xingjubuyi:addEffect('maxcards',{
    correct_func = function(self, player)
        if player.chained then
            local num = #table.filter(Fk:currentRoom().alive_players, function(p)
                return p:hasSkill(self)
            end)
            return 2 * num
        end
    end,
})

Fk:loadTranslationTable {
    ["mcdh_xingjubuyi"] = "笃行",
    [":mcdh_xingjubuyi"] = "『行矩不移』<br>锁定技，手牌数大于体力值的角色出牌阶段结束时，其横置；已横置的角色手牌上限+2。当你死亡时，你的下家获得此技能。",
}

return xingjubuyi